package factory_pattern.simple_factory_pattern;

/**
 * 硬币工厂
 */
public class CoinFactory {

    /**
     * 获得硬币
     * @param type 类型
     * @return
     */
    public static Coin getCoin(int type) {
        switch (type) {
            case 1:
                return new GoldCoin();
            case 2:
                return new CopperCoin();
            default:
                throw new IllegalArgumentException("没有该类型的硬币");
        }
    }
}
